package com.hzcx.app.simplechat.ui.group;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;

import com.hzcx.app.simplechat.api.BaseObserver;
import com.hzcx.app.simplechat.base.BaseEmptyBean;
import com.hzcx.app.simplechat.model.GroupModel;
import com.hzcx.app.simplechat.ui.group.LiveData.GroupInfoBeanLiveData;
import com.hzcx.app.simplechat.ui.group.bean.GroupInfoBean;


public class GroupManagerDeleteActivity extends ChatGroupDeleteMemberActivity {

    @Override
    public void initView() {
        super.initView();
        tvTitle.setText("移出管理员");
    }

    public void deleteMember(String ids) {
        GroupModel.deleteAdminGroup(this, groupID, ids, new BaseObserver<BaseEmptyBean>() {
            @Override
            protected void onSuccess(BaseEmptyBean data) {
                GroupModel.getGroupInfo(GroupManagerDeleteActivity.this, groupID, new BaseObserver<GroupInfoBean>() {
                    @Override
                    protected void onSuccess(GroupInfoBean data) {
                        data.setMembersCount(data.getMembers().size());
                        data.save();
                        GroupInfoBeanLiveData.update(data);
                        hideLoading();
                        finish();
                    }

                    @Override
                    public void onFailure(Throwable e, String errorMsg) {
                        hideLoading();
                        finish();
                    }
                });
            }

            @Override
            public void onFailure(Throwable e, String errorMsg) {
                hideLoading();
                showError("操作失败，请重试");
            }
        });
    }
}
